<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
   <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更新数据页面</title>

<head>
<meta charset="UTF-8">
<title>注册页面</title>
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/basevalue.js"></script>
<script type="text/javascript" src="scripts/cookie_util.js"></script>
<link rel="stylesheet" href="css/log.css" /> 
<script >
	$(function(){
		var userId=getCookie("uid");
		console.log(userId);
		if(userId==null){
			window.location.href="login.html";
		}
		var flag=false;
		var name=getCookie("thisname");
			$("#name").val(name);
	
		//密码输入验证	
		$("#password").blur(function(){
			var	password=$("#password").val().trim();
			$("#paw_span").html("");
			flag=true;
			console.log(password);
			if(password.length<8){
				$("#paw_span").html("用户密码过短");
				flag=false;
			}
		});
		$("#passwords").blur(function(){
			flag=true;
			$("#paws_span").html("");
			var	password=$("#password").val().trim();
			var passwords=$("#passwords").val().trim();
			if(password!=passwords){
				$("#paws_span").html("两次密码输入不一致");
				flag=false;	
			}
		});
		$("#phon").blur(function(){
			flag=true;
			$("#phon_span").html(""); 
			var phon=$("#phon").val().trim();
			console.log(phon);
			
			 if(phon.length<11){
				
				$("#phon_span").html("电话输入不足11位");
				flag=false;	
			}
			console.log(flag);
		});
		$("#sig_in").click(function(){
			var thisId=getCookie("thisId");
		
			var	password=$("#password").val().trim();
			var phon=$("#phon").val().trim();
			if(flag){
				$.ajax({
					url:base_path+"/update.do",
					type:"post",
					data:{"Id":thisId,"password":password,"phon":phon},
					dataType:"json",
					success:function(result){
						if(result.status==0){
							alert("修改成功");
							window.location.href="success.do";
						}if(result.status==1){
							alert(result.mgs);
							
						}
					},
					error:function(){
						alert("网络异常");
					}
				});	
			}
		});
	$("#login").click(function(){
		window.location.href="success.do";
	});
		
	});
</script>
</head>
<body>
		<div class="login">
		<h1>修改信息</h1>
	用户名:&nbsp;<input type="text" id="name" readonly="readonly"><br><br>		
	密&nbsp;码:&nbsp;<input type="password" id="password">
		<span style="color: red" id="paw_span"></span><br><br>
	确认密码:<input type="password" id="passwords">
		<span style="color: red" id="paws_span"></span><br><br>
	电&nbsp;话&nbsp;:<input type="text" id="phon">
		<span style="color: red" id="phon_span"></span><br><br>	
		<div align="center">
		<span style="color: red" id="resu_span"></span>
		<br>
		<input type="button" id ="sig_in" value="确定">
		<input type="button" id ="login" value="返回">
		</div>
	</div>
</body>
</html>

